package com.rx.biz;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;
import org.springside.modules.orm.hibernate.HibernateDao;

@Transactional
public abstract class BaseBiz<T, PK extends Serializable> {

	protected HibernateDao<T, PK> dao;

	public abstract void setDao(HibernateDao<T, PK> dao);

	@Transactional(readOnly = true)
	public T get(PK id) {
		return dao.get(id);
	}

	public void save(T entity) {
		dao.save(entity);
	}

	public void delete(PK id) {
		dao.delete(id);
	}

	@Transactional(readOnly = true)
	public List<T> search() {
		return dao.getAll();
	}

	@Transactional(readOnly = true)
	public Page<T> search(final Page<T> page, final List<PropertyFilter> filters) {
		return dao.findPage(page, filters);
	}

}
